<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    var cut = prompt("请输入样例：");
    var cutarr = new Array();
    var arr = new Array();
    var k = 0;
    for(var i = 0;i < cut.length;i++)
{ 
    //var cutchar = cut[i];//将数组元素存入cutchar中
    if(cut[i] == ' ')//遇到空格停下判断开始切割字符
{
    var num = cutarr;
    arr[k++] = Number(num);//将纯入的字符插入tmp中，再滞空cutarr
    cutarr = '';
}
else{
    cutarr =cutarr + cut[i];//如果没遇到空格，继续向cutarr插入字符
}
}
if(cutarr.length > 0)//如果cutarr还有多余的字符将其插入tmp中
{
    var num = cutarr;
    arr[k] = Number(num);
}
        var n = arr.length//开始冒泡无需多说
        for (var i = 0; i < n - 1; i++) {
            for (var j = 0; j < n - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    var temp = arr[j]
                    arr[j] = arr[j + 1]
                    arr[j + 1] = temp
                }
            }
        }
        console.log(arr);
        alert("冒泡排序结果为：" + arr);
    </script>
</body>
</html>